Element¶
Element represents an individual block. It can hold a widget and handle operations with it.
While setting and removing, a child_dict
named dictionary is taken and returned.
The format of child_dict
is as follows
child_dict = {
"child": Gtk.Widget,
"child_name": str,
"icon": Gtk.Image,
"header_child": Gtk.Widget or None,
"provider": Aduct.Provider
}
Here only header_child
key is optional.
-
class
Aduct.Element.
Element
(child_dict=None, use_action_button=True, pack_type=0, **kwargs)¶ Makes an element based on given properties. Its CSS name is aduct-element.
Parameters: - child_dict (
dict
) – A dictionary object containing properties of child. Given a valid dictionary, the child is added toself
while initializing. It isNone
, when not given. - use_action_button (
bool
) – States whether to use an action button. Default isTrue
. - pack_type (
Gtk.PackType
) – Specfies the position of action button. It can be an integer of value either 0 or 1, which representsGtk.PackType.START
orGtk.PackType.END
respectively. The default value isGtk.PackType.START
. - **kwargs – The values to be passed to
Gtk.Grid
, from whichElement
is derived.
Action button that is used to handle interactions with user. Its default name is aduct-element-action_button.
Type: Gtk.Button
-
pack_type
¶ The position of action button in
self
.Type: Gtk.PackType
-
Signals
¶ - action-clicked
- Emitted with an integer when action button of
self
is clicked. The integer is 1, 2, 3 for LMB, MMB, RMB respectively. - child-added
- Emitted when a child is added to
self
. - child-cleared
- Emitted when the child of
self
is cleared. - child-removed
- Emitted when the child of
self
is removed.
Note
Incase having
use_action_button
asFalse
, an action button is still created, but is not attached to theself
.-
clear_child
()¶ Clears the child at
self
. After clearing,child-cleared
signal is emitted.
Removes the action button of
self
. Nothing is done if it is already disabled.
Adds the action button of
self
. Nothing is done if it is already enabled.
-
get_child
()¶ Gets the child held by
self
.Returns: The child of self
orNone
ifself
has no child.Return type: Gtk.Widget
orNone
-
get_child_name
()¶ Gets the name of child held by
self
.Returns: The child name of self
orNone
ifself
has no child.Return type: str
orNone
-
get_header_child
()¶ Gets the child packed at the header of
self
.Returns: The header child of self
orNone
ifself
has no header child.Return type: Gtk.Widget
orNone
-
get_icon
()¶ Gets the icon representing child held by
self
.Returns: The icon of action_button
orNone
ifself
has no icon for child.Return type: Gtk.Image
orNone
-
get_props
()¶ Gets the properties of child held by
self
.Returns: The dictionary that can be later used to build the same interface. Return type: dict
-
get_provider
()¶ Gets the provider for child held by
self
.Returns: The provider of self
orNone
ifself
has no child.Return type: Provider
orNone
-
remove_child
()¶ Removes the child held by
self
.By removing a child, all its associated properties like icon, header child are also removed. A
child-removed
signal is emitted byself
after removal.Raises: ValueError
– Raised whenself
has no child.Returns: A dictionary with child properties. Return type: dict
-
set_child
(child_dict)¶ Sets the child in
self
from given properties.If
self
already has a child, then its cleared before adding this new child. Achild-added
signal is emitted after addition.Parameters: child_dict ( dict
) – A valid dictionary with properties of child.
-
set_child_name
(child_name)¶ Sets the name of child held by
self
.Parameters: child_name ( str
) – The new name of child.
-
set_from_props
(props)¶ Sets the interface of
self
from given properties.If
self
already has a child, then its cleared before adding this new child.Parameters: props ( dict
) – The dictionary from which properties are set.
-
set_header_child
(header_child)¶ Sets the header child of
self
.Parameters: header_child ( Gtk.Widget
) – The new header child ofself
.
-
set_icon
(icon)¶ Sets the icon of child held by
self
.Parameters: icon ( Gtk.Image
) – The new icon of child.
-
set_provider
(provider)¶ Sets the provider of child held by
self
.Parameters: provider ( Provider
) – The new provider of child.
-
type
¶ Used by autodoc_mock_imports.
- child_dict (